import React, {Component} from 'react';
import classnames from 'classnames';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;


export default class Content extends Component{
    sign = () => {
        const {data} = this.props;
        this.props.sign && this.props.sign({...data, position: '', longitude: '', latitude: '', sid: '', mac: '', deviceId: '',deviceInfo: ''});
    }

    render(){
        const {data, activeIndex, currIndex} = this.props;
        const statusObj = this.props.convertStatus(data.status || data.signfrom || '');
        const obj = {
            status: true
        }
        statusObj != null && Object.assign(obj, {[statusObj.className]: true});
        const statusClassName = classnames(obj);

        return (
            <div className='content'>
                {
                    ((activeIndex === -1 || activeIndex > currIndex) || (data.signTime != null && data.signTime.trim().length > 0)) &&
                    <div className='signData'>
                    {
                        data.signTime != null && data.signTime.trim().length > 0 &&
                        <div className='signTime text-elli' title={`${getLabel('18949','打卡时间')} ${data.signbelongspan || ''} ${data.signTime}`}>{`${getLabel('18949','打卡时间')} ${data.signbelongspan || ''} ${data.signTime}`}</div>
                    }
                    {
                        ((activeIndex === -1 || activeIndex > currIndex) || (data.signTime != null && data.signTime.trim().length > 0)) &&
                        <div className={statusClassName}>{statusObj.label}</div>
                    }
                    </div>
                }
                {
                    data.position != null && data.position.trim().length > 0 &&
                    <div className='position'>
                        <div className='icon-coms-position positionIcon'></div>
                        <div className='positionInfo text-elli' title={data.position || ''}>{data.position || ''}</div>
                    </div>
                }
                {
                    data.reSign == '1' &&
                    <div><a className='resign' onClick={this.sign}>{getLabel('500498','更新打卡时间')}</a></div>
                }
                {
                    ((activeIndex === -1 || activeIndex > currIndex) && data.status != null && ['0', '1'].indexOf(data.status) < 0) &&
                    <div><a className='workflow' onClick={this.props.showWorkflow}>{getLabel('500499','提交流程')}</a></div>
                }
            </div>
        )
    }
}